home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3p / usgetinfo.z / usgetinfo
Encoding:
Text File  |  2002-10-03  |  3.6 KB  |  67 lines

  1.  
  2.  
  3.  
  4. UUUUSSSSGGGGEEEETTTTIIIINNNNFFFFOOOO((((3333PPPP))))                                                    UUUUSSSSGGGGEEEETTTTIIIINNNNFFFFOOOO((((3333PPPP))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      usgetinfo, usputinfo, uscasinfo - exchange information though an arena
  10.  
  11. CCCC SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<uuuulllloooocccckkkkssss....hhhh>>>>
  13.  
  14.      vvvvooooiiiidddd uuuussssppppuuuuttttiiiinnnnffffoooo ((((uuuussssppppttttrrrr____tttt ****hhhhaaaannnnddddlllleeee,,,, vvvvooooiiiidddd ****iiiinnnnffffoooo))));;;;
  15.  
  16.      vvvvooooiiiidddd ****uuuussssggggeeeettttiiiinnnnffffoooo ((((uuuussssppppttttrrrr____tttt ****hhhhaaaannnnddddlllleeee))));;;;
  17.  
  18.      iiiinnnntttt uuuussssccccaaaassssiiiinnnnffffoooo ((((uuuussssppppttttrrrr____tttt ****hhhhaaaannnnddddlllleeee,,,, vvvvooooiiiidddd ****oooolllldddd,,,, vvvvooooiiiidddd ****nnnneeeewwww))));;;;
  19.  
  20. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  21.      When unrelated processes decide to share an arena, it is often useful to
  22.      be able to initially communicate the location of various data structures
  23.      within the arena.  A single word (doubleword in 64 bit mode)
  24.      communication area is available inside the arena header block, accessible
  25.      via the functions _u_s_g_e_t_i_n_f_o and _u_s_p_u_t_i_n_f_o.  Thus, a process that sets up
  26.      the arena can initialize various locks, semaphores, and common data
  27.      structures, and place a single pointer that any process that joins the
  28.      arena can retrieve.  _u_s_p_u_t_i_n_f_o places the data item in the header,
  29.      overwriting any existing information there.  _u_s_g_e_t_i_n_f_o will retrieve that
  30.      information.  At arena creation time, the value is initialized to zero.
  31.  
  32.      If multiple unrelated processes are starting at arbitrary times, then a
  33.      race condition exists between initializing the arena and setting the
  34.      global information.  The _u_s_c_a_s_i_n_f_o function provides a compare and swap
  35.      operation on the data item in the arena header block.  To establish race
  36.      free initialization, each joining member should first check the data item
  37.      using _u_s_g_e_t_i_n_f_o and if 0 should allocate a semaphore (using _u_s_n_e_w_s_e_m_a).
  38.      The caller should then use _u_s_c_a_s_i_n_f_o to atomically place the semaphore
  39.      pointer into the communication area.  If _u_s_c_a_s_i_n_f_o returns 0 then someone
  40.      else may have beat the caller and the caller should free the semaphore
  41.      and repeat the algorithm starting with re-checking _u_s_g_e_t_i_n_f_o.  Note that
  42.      even with one process performing this algorithm, the compare and swap
  43.      operation may fail, so the caller must always be prepared to loop.  If 1
  44.      is returned, then the caller has won and can use the semaphore for future
  45.      negotiation.
  46.  
  47. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  48.      usinit(3P).
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.